package com.example.fitnessservice.module.dao.usermapper;

import com.example.fitnessservice.module.pojo.UserInfo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface MyMapper {

    /**
     * 查询用户的个人信息
     * @param userId
     * @return
     */
    @Select("select * from user_info where user_id = #{userId}")
    public UserInfo findMyInfo(Integer userId);

    /**
     * 添加用户的个人信息
     * @param userInfo
     * @return
     */
    @Insert("insert into user_info (user_id, monicker, height, gender, birthday, city, industry, income, education, marriage, signature, phone, image) values (#{userId}, #{monicker}, #{height}, #{gender}, #{birthday}, #{city}, #{industry}, #{income}, #{education}, #{marriage}, #{signature}, #{phone}, #{image})")
    public int addMyInfo(UserInfo userInfo);

    /**
     * 修改用户的个人信息，不包括头像
     * @param userInfo
     * @return
     */
    @Update("update user_info set monicker = #{monicker}, height = #{height}, gender = #{gender}, birthday = #{birthday}, city = #{city}, industry = #{industry}, income = #{income}, education = #{education}, marriage = #{marriage}, signature = #{signature}, phone = #{phone} where user_id = #{id}")
    public int updateMyInfo(UserInfo userInfo);
}
